package com.enation.app.shop.front.policyInsurance.adminController;

import com.enation.app.base.core.model.Member;
import com.enation.app.base.core.service.IMemberManager;
import com.enation.app.shop.core.goods.model.Cat;
import com.enation.app.shop.core.goods.service.IGoodsCatManager;
import com.enation.app.shop.front.policyInsurance.area.service.ProvinceManager;
import com.enation.app.shop.front.policyInsurance.entity.ClaimApplication;
import com.enation.app.shop.front.policyInsurance.service.ClaimApplicationMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import java.text.SimpleDateFormat;
import java.util.List;

@Scope("prototype")
@Controller
@RequestMapping("/admin/insurance")
public class ViewController {

    @Autowired
    private IMemberManager memberManager;
    @Autowired
    private ProvinceManager provinceManager;
    @Autowired
    private IGoodsCatManager goodsCatManager;
    @Autowired
    private ClaimApplicationMapper  claimApplicationMapper;
    //添加供应商跳转页面
    @RequestMapping(value="/addsupplier")
    public ModelAndView claims(Model model){
        ModelAndView view = new ModelAndView();
        view.setViewName("/shop/admin/admininsurance/addSupplier");
        return view;
    }

    //添加保险公司员工负责区域跳转页面
    @RequestMapping(value="/addstaffarea")
    public ModelAndView staff(Model model){
        ModelAndView view = new ModelAndView();
        List<Cat> cats= goodsCatManager.listChildren(244);
        model.addAttribute("cat2Id",cats);
        List<Member> member= memberManager.getByMemberType(2);
        model.addAttribute("member",member);
        view.setViewName("/shop/admin/admininsurance/addstaffarea");
        return view;
    }



    //保险公司员工负责区域列表跳转页面
    @RequestMapping(value="/staffarealist")
    public ModelAndView insurancelist(Model model){
        ModelAndView view = new ModelAndView();
        view.setViewName("/shop/admin/admininsurance/staffarealist");
        return view;
    }


    //银行卡列表跳转页面
    @RequestMapping(value="/bankcardlist")
    public ModelAndView bankcardlist(Model model){
        ModelAndView view = new ModelAndView();
        view.setViewName("/shop/admin/admininsurance/bankcardlist");
        return view;
    }

    //供应商列表跳转页面
    @RequestMapping(value="/supplierlist")
    public ModelAndView supplierlist(Model model){
        ModelAndView view = new ModelAndView();
        view.setViewName("/shop/admin/admininsurance/supplierList");
        return view;
    }


    @RequestMapping(value="/addinsurancetest")
    public ModelAndView addinsurancetest(Model model){
        ModelAndView view = new ModelAndView();
        view.setViewName("/shop/admin/admininsurance/imgtest");
        return view;
    }


    //理赔列表跳转页面
    @RequestMapping(value="/getClaimList")
    public ModelAndView getClaimList(Model model) {
        ModelAndView view = new ModelAndView();
        view.setViewName("/shop/admin/admininsurance/claimlist");
        return view;
    }
    @RequestMapping(value="/patrol/enddetail")
    public ModelAndView addinsurancetest1(Model model,Integer id){
        System.out.println(id);
        ModelAndView view = new ModelAndView();
        view.setViewName("/shop/admin/admininsurance/imgtest1");
        Member member= memberManager.getapp(1003);
        model.addAttribute("member",member);
        return view;
    }


    //理赔列表跳转页面
    @RequestMapping(value="/getClaimDetail")
    public ModelAndView getClaimDetail(Model model,Long id){
        ModelAndView view = new ModelAndView();
        ClaimApplication claimApplication= claimApplicationMapper.selectByPrimaryKey(id);
        model.addAttribute("claimsSettlement",claimApplication);
        Long casedate=claimApplication.getCase_date().getTime();
        SimpleDateFormat sdf= new SimpleDateFormat("yyyy-MM-dd");
        String str = sdf.format(casedate);
        model.addAttribute("casedate",str);
        view.setViewName("/shop/admin/admininsurance/claimdetail");
        return view;
    }
}
